package com.xm.service.controller;

import com.xm.service.framework.feign.BookFeignClient;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import xm.common.book.entity.Book;

import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
@RequestMapping("/consumer/book")
public class ConsumerBookController {

    private final BookFeignClient bookFeignClient;
    /**
     * book-consumer 服务
     * @return
     */
    @RequestMapping("/list")
    public List<Book> list(){
        return bookFeignClient.list();
    }

    @PostMapping("/add")
    public String  add(@RequestParam String author, @RequestParam int stock,
                       @RequestParam String name, @RequestParam String date){
        return bookFeignClient.add(author,stock,name,date);
    }



    @DeleteMapping("/delete")
    String deleteById(@RequestParam int id){
        return bookFeignClient.deleteById(id);
    }

    @PutMapping("/update")
    String updateStockByid(@RequestParam int id,@RequestParam int stock){
        return bookFeignClient.updateStockByid(id,stock);
    }



}
